﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>@ViewBag.ProjectName-QuartzUI出品</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="@ViewBag.LogoIcon">
    <link rel="stylesheet" href="~/lib/layui/css/layui.css?v=@QuartzUI.Code.GlobalContext.GetVersion()" media="all">
    <link rel="stylesheet" href="~/css/login.css?v=@QuartzUI.Code.GlobalContext.GetVersion()" media="all">
</head>

<body>
    <script src="~/lib/jquery-3.4.1/jquery-3.4.1.min.js?v=@QuartzUI.Code.GlobalContext.GetVersion()" charset="utf-8"></script>
    <script src="~/js/cookie/jquery.cookie.js?v=@QuartzUI.Code.GlobalContext.GetVersion()"></script>
    <script src="~/js/md5/base64.js?v=@QuartzUI.Code.GlobalContext.GetVersion()"></script>
    <script src="~/js/md5/jquery.md5.js?v=@QuartzUI.Code.GlobalContext.GetVersion()"></script>
    <script src="~/lib/layui/layui.js?v=@QuartzUI.Code.GlobalContext.GetVersion()" charset="utf-8"></script>
    <script src="~/js/lay-config.js?v=@QuartzUI.Code.GlobalContext.GetVersion()" charset="utf-8"></script>
    <script src="~/js/framework-ui.js?v=@QuartzUI.Code.GlobalContext.GetVersion()"></script>
    <script>
        layui.use(['jquery', 'form', 'table', 'common', 'commonTable', 'echarts'], function () {
        });
    </script>
    @*动画特效*@
    <div id="starsBox"></div>
    <div class="layui-container">
        <div class="admin-login-background">
            <div class="layui-form login-form">
                <div class="logo-title">
                    <h1>@ViewBag.ProjectName</h1>
                </div>
                <div class="layui-form-item">
                    <label class="layui-icon layui-icon-username" for="username"></label>
                    <input type="text" id="username" disabled lay-verify="required|account" placeholder="用户名" autocomplete="off" class="layui-input" value="admin">
                </div>
                <form class="layui-form" action="">
                    <div class="layui-form-item">
                        <label class="layui-icon layui-icon-password" for="password"></label>
                        <input type="password" id="password" lay-verify="required|password" placeholder="登录密码" autocomplete="off" class="layui-input" value="@ViewBag.Password">
                    </div>
                    <div class="layui-form-item">
                        <div class="login_tips"></div>
                        <button id="login_button" class="layui-btn layui-btn-fluid" style="background-color:#FFFFCE;color:orange" lay-submit="" lay-filter="login">登 入</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script src="~/js/login.js?v=@QuartzUI.Code.GlobalContext.GetVersion()"></script>
    <script>
        (function ($) {
            $.login = {
                formMessage: function (msg) {
                    $('.login_tips').find('.tips_msg').remove();
                    $('.login_tips').append('<div class="tips_msg"><i class="fa fa-question-circle"></i>' + msg + '</div>');
                },
                init: function () {
                    var login_error = top.$.cookie('QuartzUI_login_error');
                    if (login_error != null) {
                        switch (login_error) {
                            case "overdue":
                                $.login.formMessage('系统登录已超时,请重新登录');
                                break;
                            case "OnLine":
                                $.login.formMessage('您的帐号已在其它地方登录,请重新登录');
                                break;
                            case "-1":
                                $.login.formMessage('系统未知错误,请重新登录');
                                break;
                        }
                        top.$.cookie('QuartzUI_login_error', '', { path: "/", expires: -1 });
                    }
                },
                checkLogin: function () {
                    $.ajax({
                        url: "/Login/CheckLoginState?v=" + new Date().Format("yyyy-MM-dd hh:mm:ss"),
                        type: "post",
                        async: false,
                        dataType: "json",
                        success: function (data) {
                            if (data.state == "success") {
                                window.location.href = '@Url.Content("~/Home/Index")';
                            }
                        }
                    });
                }
            };
            $(function () {
                sessionStorage.setItem('QuartzUIButtonHumanized',"1111");
                $.login.init();
                $.login.checkLogin();
            });
            layui.use(['form'], function () {
                var form = layui.form,
                    layer = layui.layer;
                // 进行登录操作
                form.on('submit(login)', function (data) {
                    data = data.field;
                    if (data.username == '') {
                        layer.msg('用户名不能为空');
                        return false;
                    }
                    if (data.password == '') {
                        layer.msg('密码不能为空');
                        return false;
                    }
                    $("#login_button").empty();
                    $("#login_button").attr('disabled', 'disabled').html("loading...");
                    $.ajax({
                        url: "/Login/CheckLogin?v=" + new Date().Format("yyyy-MM-dd hh:mm:ss"),
                        data: { username: $.trim($('#username').val()), password: $.md5($.trim($('#password').val())) },
                        type: "post",
                        dataType: "json",
                        success: function (data) {
                            if (data.state == "success") {
                                $("#login_button").empty();
                                $("#login_button").html("登录成功，正在跳转...");
                                window.location.href = '@Url.Content("~/Home/Index")';
                            } else {
                                $("#login_button").empty();
                                $("#login_button").removeAttr('disabled').html("登 入");
                                layer.msg(data.message);
                                $.login.formMessage(data.message);
                            }
                        },
                        error: function () {
                            $("#login_button").empty();
                            $("#login_button").removeAttr('disabled').html("登 入");
                            layer.msg("系统未知错误,请重新登录");
                            $.login.formMessage("系统未知错误,请重新登录");
                        }

                    });

                    return false;
                });
            });
        })(jQuery);
    </script>
</body>
</html>